package com.mt.vsphere.business.vsphere;


import com.mt.vsphere.business.bean.base.VCenterCatalogue;
import com.vmware.vim25.ManagedObjectReference;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
public class VCenterDataHelper {


    public VCenterConnectHelper vCenterConnectHelper;
    public Map<String, ManagedObjectReference> mobMap = new HashMap<>();


    public List<VCenterCatalogue> getCatalogues() {
        return VCenterCatalogueUtil.getVCenterCatalogue(this);
    }

    public Object getVirtualMachineAttr(String type,String value){
        try {
            return VMAttr.getAttr(vCenterConnectHelper,mobMap.get(type+"@"+value));
        } catch (Exception e) {
            e.printStackTrace();
            log.info("获取虚拟机参数失败");
            return null;
        }
    }

    public VCenterDataHelper(String url, String userName, String password) {
        vCenterConnectHelper = new VCenterConnectHelper();
        vCenterConnectHelper.connect(url, userName, password);
    }



}
